package io.gitee.yth.design.pattern.test.core.pattern.creational.factory.pizzaorderservice;

import io.gitee.yth.design.pattern.test.core.pattern.creational.factory.pizza.ChicagoStyleCheesePizza;
import io.gitee.yth.design.pattern.test.core.pattern.creational.factory.pizza.ChicagoStylePepperPizza;
import io.gitee.yth.design.pattern.test.core.pattern.creational.factory.pizza.Pizza;

/**
 * @author yth
 * @since 2023-04-17-11:45
 */
public class ChicagoPizzaOrderService extends AbstractPizzaOrderService {
    @Override
    public Pizza orderPizza(String orderType) {
        Pizza pizza = this.createPizza(orderType);
        if (pizza == null) return null;
        pizza.prepare();
        pizza.bake();
        pizza.cut();
        pizza.box();
        return pizza;
    }

    @Override
    protected Pizza createPizza(String orderType) {
        switch (orderType) {
            case "cheese":
                return new ChicagoStyleCheesePizza();
            case "pepper":
                return new ChicagoStylePepperPizza();
            default:
                return null;
        }
    }
}
